package com.koron.tool.listener.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.koron.tool.bean.ToolBean;
import com.koron.tool.enums.InventoryStatusEnum;
import com.koron.tool.util.ToolConstant;
import lombok.Getter;
import lombok.SneakyThrows;

import java.util.ArrayList;
import java.util.List;


/**
 * @Author: laiguangming
 * @Date: 2023/4/28 17:22
 */
@Getter
public class ImportToolDataListener extends AnalysisEventListener<ToolBean> {

    private List<ToolBean> toolBeanList = new ArrayList<>();

    @SneakyThrows
    @Override
    public void invoke(ToolBean toolBean, AnalysisContext context) {
        toolBean.setCode(toolBean.getRFID());
        toolBean.setInventoryStatus(InventoryStatusEnum.IN_INVENTORY.getValue());
        toolBean.setAvailableStatus(ToolConstant.AVAILABLE_STATUS_AVAILABLE);
        toolBeanList.add(toolBean);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }

}
